package jllowrey.controller;

import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTextField;

import jllowrey.model.DecisionLinesEvent;
import jllowrey.view.Application;
import jllowrey.view.DrawingPanel;
/**
 * the begin button controller handles if the button is pressed enable the ability to draw edges
 * 
 * @author J Lowrey
 *
 */
public class BeginButtonController implements ActionListener{

	DecisionLinesEvent event;
	Application view;
	
		
	/**
	 * the constructor for the button
	 * 
	 * @param dle, the event
	 * @param app, the gui
	 */
	public BeginButtonController(DecisionLinesEvent dle, Application app){
		event = dle;
		view = app;		
	}
	
	
/**
 * 
 * if the begin button is pressed enable drawing edges, disable edit function of textfields,
 * and make the button not visable
 * 
 */
	@Override
	public void actionPerformed(ActionEvent e) {		

		System.out.println("Begin button pressed");
		
		/** disable all the choices text fields */
		for (int i = 0; i < event.numChoices; i++) {
			view.choices[i].setEditable(false);
		}
		
		/** disable button */
		view.getButton().setVisible(false);
				

		/** created a new DrawEdgeController to register mouse events */
		DrawEdgeController drawController = new DrawEdgeController(event, view);	
		view.getDrawingPanel().addMouseListener(drawController);		
	}
}
